//
//  YDContactDetailHeaderCell.m
//  IngCard
//
//  Created by kf on 2017/10/16.
//  Copyright © 2017年 IngDan. All rights reserved.
//

#import "YDContactDetailSectionHeaderView.h"

@interface YDContactDetailSectionHeaderView()
@property(nonatomic, strong) UILabel *titleLabel;
@property(nonatomic, strong) UIButton *actionButton;
@end

@implementation YDContactDetailSectionHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initSubviews];
    }
    return self;
}


-(void) initSubviews
{
    [self addSubview:self.titleLabel];
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(20);
        make.top.equalTo(14);
    }];
    
    [self addSubview:self.actionButton];
    [self.actionButton makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-15);
        make.centerY.equalTo(self.titleLabel);
    }];
}

- (void)plusButtonAction:(UIButton *)btn
{
    BlockGoGo(self.onMore);
}

#pragma mark - lazy load
-(void) setTitle:(NSString *)title
{
    _title = title;
    self.titleLabel.text = title;
}

-(UILabel *) titleLabel
{
    if (!_titleLabel)
    {
        _titleLabel = [UILabel new];
        _titleLabel.text = @"Experience";
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.font = [UIFont boldSystemFontOfSize:17];
        _titleLabel.textColor = UIColorMake(3, 3, 3);
    }
    return _titleLabel;
}

-(UIButton *) actionButton
{
    if (!_actionButton)
    {
        _actionButton = [[UIButton alloc] init];
        _actionButton.frame = CGRectMake(0, 0, 24, 25);
        _actionButton.layer.masksToBounds = YES;
        [_actionButton setImage:UIImageMake(@"contact_detail_more") forState:UIControlStateNormal];
        [_actionButton addTarget:self
                        action:@selector(plusButtonAction:)
              forControlEvents:UIControlEventTouchUpInside];
        [_actionButton sizeToFit];
    }
    return _actionButton;
}
@end
